package com.zhou.jiancai.activity;

import android.graphics.Point;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;

import com.github.amlcurran.showcaseview.ShowcaseView;
import com.github.amlcurran.showcaseview.targets.Target;
import com.github.amlcurran.showcaseview.targets.ViewTarget;
import com.zhou.jiancai.R;


/**
 * Created by Administrator on 2017/5/24.
 */

public class ShowcaseActivity  extends AppCompatActivity  implements View.OnClickListener{

    private Button button;
    private Button button1;
    private Button button2;
    private Button button3;
    private Button button4;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.showcase_activity);
        final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_showcase);
        button = (Button) findViewById(R.id.but_showcase);
        button1 = (Button) findViewById(R.id.but1_showcase);
        button2 = (Button) findViewById(R.id.but2_showcase);
        button3 = (Button) findViewById(R.id.but3_showcase);
        button4 = (Button) findViewById(R.id.but4_showcase);
        button.setOnClickListener(this);
        button1.setOnClickListener(this);
        button2.setOnClickListener(this);
        button3.setOnClickListener(this);
        button4.setOnClickListener(this);



        final Target viewTarget = new Target() {
            @Override
            public Point getPoint() {
                return new ViewTarget(toolbar).getPoint();
            }
        };

        new ShowcaseView.Builder(this)
                .setTarget(viewTarget)
                .setContentTitle("ShowcaseView")
                .setContentText("This is highlighting the Home button")
                .hideOnTouchOutside()
                .build();
        //new ActionViewTarget(this, ActionViewTarget.Type.HOME)

    }

    @Override
    public void onClick(View v) {
        final Target viewTarget ;
        switch (v.getId()){

            case R.id.but_showcase:
             viewTarget = new Target() {
                    @Override
                    public Point getPoint() {
                        return new ViewTarget(button).getPoint();
                    }
                };

                new ShowcaseView.Builder(this)
                        .setTarget(viewTarget)
                        .setContentTitle("ShowcaseView")
                        .setContentText("This is highlighting the Home button")
                        .hideOnTouchOutside()
                        .build();
                break;
            case R.id.but1_showcase:
                viewTarget = new Target() {
                    @Override
                    public Point getPoint() {
                        return new ViewTarget(button1).getPoint();
                    }
                };

                new ShowcaseView.Builder(this)
                        .setTarget(viewTarget)
                        .setContentTitle("ShowcaseView")
                        .setContentText("This is highlighting the Home button")
                        .hideOnTouchOutside()
                        .build();
                break;
            case R.id.but2_showcase:
              viewTarget = new Target() {
                    @Override
                    public Point getPoint() {
                        return new ViewTarget(button2).getPoint();
                    }
                };

                new ShowcaseView.Builder(this)
                        .setTarget(viewTarget)
                        .setContentTitle("ShowcaseView")
                        .setContentText("This is highlighting the Home button")
                        .hideOnTouchOutside()
                        .build();
                break;
            case R.id.but3_showcase:
               viewTarget = new Target() {
                    @Override
                    public Point getPoint() {
                        return new ViewTarget(button3).getPoint();
                    }
                };

                new ShowcaseView.Builder(this)
                        .setTarget(viewTarget)
                        .setContentTitle("ShowcaseView")
                        .setContentText("This is highlighting the Home button")
                        .hideOnTouchOutside()
                        .build();
                break;
            case R.id.but4_showcase:
                viewTarget =  new Target() {
                    @Override
                    public Point getPoint() {
                        return new ViewTarget(button4).getPoint();
                    }
                };

                new ShowcaseView.Builder(this)
                        .setTarget(viewTarget)
                        .setContentTitle("ShowcaseView")
                        .setContentText("This is highlighting the Home button")
                        .hideOnTouchOutside()
                        .build();
                break;
        }
    }
}
